package com.knezevic.realestate.pages;

import com.knezevic.realestate.Advert;
import com.knezevic.realestate.Privilege;
import com.knezevic.realestate.TypeOfAdvert;
import com.knezevic.realestate.TypeOfRealEstate;
import com.knezevic.realestate.beans.AdvertBean;
import com.knezevic.realestate.beans.MemberBean;
import com.knezevic.realestate.beans.RealEstateBean;
import com.knezevic.realestate.service.Adverts;
import com.knezevic.realestate.service.Members;
import com.knezevic.realestate.service.RealEstates;
import com.knezevic.realestate.util.Formats;
import java.util.LinkedHashMap;
import org.apache.tapestry5.ioc.annotations.Inject;

/**
 * Start page of application realestate.
 */
public class Index
{
    @Inject
    private Members members;
    @Inject
    private Adverts adverts;
    @Inject
    private RealEstates realEstates;

    public Object onActivate(){
        RealEstateBean r1 = new RealEstateBean(TypeOfRealEstate.Apartment, "Belgrade", 86.5, 125000.00, "Great apartment");
        RealEstateBean r2 = new RealEstateBean(TypeOfRealEstate.Apartment, "London", 125.9, 895000.61, "Great apartment");
        RealEstateBean r3 = new RealEstateBean(TypeOfRealEstate.House, "New York", 155.8, 1555000.58, "Great house");
        RealEstateBean r4 = new RealEstateBean(TypeOfRealEstate.House, "Cacak", 75.8, 65000.14, "Great house");
        RealEstateBean r5 = new RealEstateBean(TypeOfRealEstate.Apartment, "Belin", 86.5, 325210.15, "Great apartment");
        RealEstateBean r6 = new RealEstateBean(TypeOfRealEstate.Apartment, "Paris", 25.9, 95000.61, "Great apartment");
        RealEstateBean r7 = new RealEstateBean(TypeOfRealEstate.CommercialProperty, "New York", 455.8, 6387900.00, "Great property");
        RealEstateBean r8 = new RealEstateBean(TypeOfRealEstate.LandProperty, "Cacak", 1275.4, 35000.58, "Great land near road");

        

        realEstates.save(r1);
        realEstates.save(r2);
        realEstates.save(r3);
        realEstates.save(r4);
        realEstates.save(r5);
        realEstates.save(r6);
        realEstates.save(r7);
        realEstates.save(r8);
        MemberBean m1 = new MemberBean("knez", "knez", "Nemanja", "Knezevic", "knez032@yahoo.com", Privilege.REGULAR, null);
        members.save(m1);
        MemberBean m2 = new MemberBean("danilo", "parta", "Danilo", "Partaljevic", "daniloparta@yahoo.com", Privilege.REGULAR, new LinkedHashMap<Long, Advert>());
        members.save(m2);
        MemberBean m3 = new MemberBean("nixman", "nixman", "Nikola", "Jovanovic", "majstorisadunava@yahoo.com", Privilege.REGULAR, new LinkedHashMap<Long, Advert>());
        members.save(m3);
        MemberBean m4 = new MemberBean("traje", "zver", "Stefan", "Trailovic", "luditraje@yahoo.com", Privilege.REGULAR, new LinkedHashMap<Long, Advert>());
        members.save(m4);
        MemberBean m5 = new MemberBean("admin", "admin", "John", "Black", "johnblack@yahoo.com", Privilege.ADMINISTRATOR, new LinkedHashMap<Long, Advert>());
        members.save(m5);
        MemberBean m6 = new MemberBean("nesa", "22", "Nebojsa", "Micic", "micic87@hotmail.com", Privilege.REGULAR, null);
        members.save(m6);
        AdvertBean a1 = new AdvertBean(m1, Formats.parseDate("01/12/2010"), TypeOfAdvert.Selling, r1,"Photo0137.jpg", true);
        adverts.save(a1);
        AdvertBean a2 = new AdvertBean(m1, Formats.parseDate("05/01/2011"), TypeOfAdvert.Buying, r2,"Photo0137.jpg", true);
        adverts.save(a2);
        AdvertBean a3 = new AdvertBean(m1, Formats.parseDate("11/02/2010"), TypeOfAdvert.Selling, r3,"Photo0137.jpg", true);
        adverts.save(a3);
        AdvertBean a4 = new AdvertBean(m2, Formats.parseDate("01/02/2010"), TypeOfAdvert.Renting, r4,"/Photo0137.jpg", true);
        adverts.save(a4);
        AdvertBean a5 = new AdvertBean(m3, Formats.parseDate("14/11/2010"), TypeOfAdvert.Selling, r5,"Photo0137.jpg", true);
        adverts.save(a5);
        AdvertBean a6 = new AdvertBean(m3, Formats.parseDate("15/12/2009"), TypeOfAdvert.Buying, r6,"Photo0137.jpg", true);
        adverts.save(a6);
        AdvertBean a7 = new AdvertBean(m4, Formats.parseDate("15/03/2008"), TypeOfAdvert.Selling, r7,"Photo0137.jpg", true);
        adverts.save(a7);
        AdvertBean a8 = new AdvertBean(m4, Formats.parseDate("14/02/2011"), TypeOfAdvert.Renting, r8,"Photo0137.jpg", true);
        adverts.save(a8);
        return Login.class;
    }
	
}
